From 3e902bb56e9626c8296e9836aa9ae19d82d48394 Mon Sep 17 00:00:00 2001
From: Ilion Beyst <ilion.beyst@gmail.com>
Date: Fri, 31 Dec 2021 11:24:25 +0100
Subject: list uploaded code bundles on bot page

---
 web/pw-server/src/routes/bots/[bot_id].svelte | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

(limited to 'web/pw-server/src/routes/bots/[bot_id].svelte')

diff --git a/web/pw-server/src/routes/bots/[bot_id].svelte b/web/pw-server/src/routes/bots/[bot_id].svelte
index 1d7994d..2556d73 100644
--- a/web/pw-server/src/routes/bots/[bot_id].svelte
+++ b/web/pw-server/src/routes/bots/[bot_id].svelte
@@ -1,19 +1,22 @@
 <script lang="ts" context="module">
   import { get_session_token } from "$lib/auth";
+import { mount_component } from "svelte/internal";
 
   export async function load({ page }) {
     const token = get_session_token();
     const res = await fetch(`/api/bots/${page.params["bot_id"]}`, {
       headers: {
         "Content-Type": "application/json",
-        "Authorization": `Bearer ${token}`,
+        Authorization: `Bearer ${token}`,
       },
     });
 
     if (res.ok) {
+      const data = await res.json();
       return {
         props: {
-          bot: await res.json(),
+          bot: data["bot"],
+          bundles: data["bundles"],
         },
       };
     }
@@ -26,7 +29,10 @@
 </script>
 
 <script lang="ts">
+  import dayjs from "dayjs";
+  
   export let bot: object;
+  export let bundles: object[];
 
   let files;
 
@@ -41,7 +47,7 @@
       method: "POST",
       headers: {
         // the content type header will be set by the browser
-        "Authorization": `Bearer ${token}`,
+        Authorization: `Bearer ${token}`,
       },
       body: formData,
     });
@@ -54,9 +60,16 @@
   {bot["name"]}
 </div>
 
-
 <div>Upload code</div>
 <form on:submit|preventDefault={submitCode}>
-  <input type="file" bind:files/>
+  <input type="file" bind:files />
   <button type="submit">Submit</button>
-</form>
\ No newline at end of file
+</form>
+
+<ul>
+  {#each bundles as bundle}
+    <li>
+      bundle created at {dayjs(bundle["created_at"]).format("YYYY-MM-DD HH:mm")}
+    </li>
+  {/each}
+</ul>
-- 
cgit v1.2.3

